reverse string c#

37

reverse string c# -

string str = "Hello World!"; // the string which you want to reverse
string reverse = "";
int length = str.Length - 1; 

while(length >= 0)
{
	reverse += str[length];
   	length--;
}

Console.WriteLine(reverse);  // output: "!dlroW olleH"

c# string reverse -

static class StringExtensions
{
public static string Reverse(this string metin)
{
return new string(metin.ToCharArray().Reverse().ToArray());
}
}

reverse string c# -

public static string Reverse( string s )
{
    char[] charArray = s.ToCharArray();
    Array.Reverse( charArray );
    return new string( charArray );
}

Comments

Submit
0 Comments